package com.yl.project.lvyou.info.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yl.framework.aspectj.lang.annotation.Log;
import com.yl.framework.aspectj.lang.enums.BusinessType;
import com.yl.project.lvyou.info.domain.SpotInfo;
import com.yl.project.lvyou.info.service.ISpotInfoService;
import com.yl.framework.web.controller.BaseController;
import com.yl.framework.web.domain.AjaxResult;
import com.yl.common.utils.poi.ExcelUtil;
import com.yl.framework.web.page.TableDataInfo;

/**
 * 旅游资讯信息Controller
 * 
 * @author yl
 * @date 2025-03-18
 */
@Controller
@RequestMapping("/lvyou/info")
public class SpotInfoController extends BaseController
{
    private String prefix = "scenemanager/info";

    @Autowired
    private ISpotInfoService spotInfoService;

    @RequiresPermissions("scenemanager:info:view")
    @GetMapping()
    public String info()
    {
        return prefix + "/info";
    }

    /**
     * 查询旅游资讯信息列表
     */
    @RequiresPermissions("scenemanager:info:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SpotInfo spotInfo)
    {
        startPage();
        List<SpotInfo> list = spotInfoService.selectSpotInfoList(spotInfo);
        return getDataTable(list);
    }

    /**
     * 导出旅游资讯信息列表
     */
    @RequiresPermissions("scenemanager:info:export")
    @Log(title = "旅游资讯信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SpotInfo spotInfo)
    {
        List<SpotInfo> list = spotInfoService.selectSpotInfoList(spotInfo);
        ExcelUtil<SpotInfo> util = new ExcelUtil<SpotInfo>(SpotInfo.class);
        return util.exportExcel(list, "info");
    }

    /**
     * 新增旅游资讯信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存旅游资讯信息
     */
    @RequiresPermissions("scenemanager:info:add")
    @Log(title = "旅游资讯信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SpotInfo spotInfo)
    {
        return toAjax(spotInfoService.insertSpotInfo(spotInfo));
    }

    /**
     * 修改旅游资讯信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SpotInfo spotInfo = spotInfoService.selectSpotInfoById(id);
        mmap.put("spotInfo", spotInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存旅游资讯信息
     */
    @RequiresPermissions("scenemanager:info:edit")
    @Log(title = "旅游资讯信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SpotInfo spotInfo)
    {
        return toAjax(spotInfoService.updateSpotInfo(spotInfo));
    }

    /**
     * 删除旅游资讯信息
     */
    @RequiresPermissions("scenemanager:info:remove")
    @Log(title = "旅游资讯信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(spotInfoService.deleteSpotInfoByIds(ids));
    }
}
